<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>CheerpJ test</title>
    <script src="https://cjrtnc.leaningtech.com/2.3/loader.js"></script>
  </head>
  <body>
	  public void setBody(String body) {
        this.headers.put("Content-Length", String.valueOf(body.length()));
        this.body = body;
    }

    public void setBodyInFile(String path) throws IOException {
        final Path filePath = Path.of(".", path);
        StringBuilder builder = new StringBuilder();
        try (BufferedReader in = new BufferedReader(new FileReader(filePath.toFile()))) {
            String str;
            while ((str = in.readLine()) != null) {
                builder.append(str);
            }
        }
        final String mimeType = Files.probeContentType(filePath);
        addHeader("Content-Type", mimeType);
        String content = builder.toString();
        setBody(content);
    }

    public void setBodyOldSchool(String path) throws IOException {
        final Path filePath = Path.of(".", path);
        final String template = Files.readString(filePath);
        final String content = template.replace(
                "{time}",
                LocalDateTime.now().toString());
        final String mimeType = Files.probeContentType(filePath);
        addHeader("Content-Type", mimeType);
        setBody(content);
    }
  </body>
  <script>
      cheerpjInit();
      cheerpjCreateDisplay(800,600);
      cheerpjRunJar("jsx.jar");
  </script>
</html>